<?php
$section = "application";
$titre = "";
$link = $section;
Session::setBackLink($link);
//create cfer
$rootPath = array(
	_LB_HOME => APPLICATION_URL_FO,
    _LB_PRODUCTS => APPLICATION_URL_FO."/products/");

$id = Request::getNumber("id");
$typeName = Request::get("type");
$type = 0;
switch ($typeName){
    case "application":
        $type = Application::TYPE_APPLICATION;
        $rootPath[_LB_APPLICATION] = APPLICATION_URL_FO."/products/application/";
        $titre =  _LB_APPLICATION;
        break;
    case "design":
        $type = Application::TYPE_DESIGN;
        $rootPath[_LB_DESIGN] = APPLICATION_URL_FO."/products/design/";
        $titre =  _LB_DESIGN;
        break;
    case "technology":
        $type = Application::TYPE_TECHNOLOGY;
        $rootPath[_LB_TECHNOLOGY] = APPLICATION_URL_FO."/products/technology/";
        $titre =  _LB_TECHNOLOGY;
        break;
    default :
        break;
}

$cateLeft = Category::getSubItem(0);

$application = new Application();
if($id > 0 && $application->get($id)){
    $smarty->assign('category', $application);
    $subCat = Category::getSubItem($id);
    $subCat = new Application();
    $subCat->getRelatedCategory($id);
    $smarty->assign('subCat', $subCat);
    
    $pathName = array();
    Application::getApplicationPathName($id, $pathName,$type);
    $utils = new Utils();
    for($i = count($pathName);$i>=0;$i--){
        if(isset($pathName[$i]) && is_array($pathName[$i])){
            $item = $pathName[$i];
            $rootPath[$item['TITLE']] = APPLICATION_URL_FO."/products/".$typeName."/".$item['ID']."/". $utils->RemoveSign($item['TITLE']);    
        }
    }
    $titre .= TITLE_PAGE_SEPARATE .$application->TITLE;
}
$path = array($id);
Application::getApplicationPath($id, $path,$type);
$arrCat = array();
Application::getAllSubItem(0, $arrCat, $path,$type);

$cfer = new Cfer($rootPath);
Session::setBackCfer($link, $cfer->getCferArray());
$smarty->assign('cfer', $cfer);
$smarty->assign('catLeft', $arrCat);
$smarty->assign('id', $id);
$smarty->assign('typeName', $typeName);
$smarty->assign('type', $type);
$smarty->assign('titre', $titre);
$smarty->display("products_application.html");